<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Escape a string so it can safely be used in an sql-statement</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.dbx-escape-string" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">dbx_escape_string</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5 &lt; 5.1.0, PECL dbx &gt;= 1.1.0)</p><p class="refpurpose"><span class="refname">dbx_escape_string</span> &mdash; <span class="dc-title">
   Escape a string so it can safely be used in an sql-statement
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.dbx-escape-string-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>dbx_escape_string</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$link_identifier</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$text</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   Escape the given string so that it can safely be used in an sql-statement.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.dbx-escape-string-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">link_identifier</code></dt>

     <dd>

      <p class="para">
       The DBX link object returned by <span class="function"><a href="dbx_connect.html" class="function">dbx_connect()</a></span>
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">text</code></dt>

     <dd>

      <p class="para">
       The string to escape.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.dbx-escape-string-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the text, escaped where necessary (such as quotes, backslashes
   etc). On error, <strong><code>NULL</code></strong> is returned.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.dbx-escape-string-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-973">
    <p><strong>Example #1 <span class="function"><strong>dbx_escape_string()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$link&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dbx_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">DBX_MYSQL</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"db"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"username"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"password"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$text&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dbx_escape_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"It\'s&nbsp;quoted&nbsp;and&nbsp;backslashed&nbsp;(\\)."</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">dbx_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"insert&nbsp;into&nbsp;tbl&nbsp;(txt)&nbsp;values&nbsp;('"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$text&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #DD0000">"')"</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$result&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">dbx_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">dbx_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$link</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.dbx-escape-string-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="dbx_query.html" class="function" rel="rdfs-seeAlso">dbx_query()</a> - Send a query and fetch all results (if any)</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>